<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	template="/WEB-INF/layout/t.xhtml">

	<ui:define name="roles">
		<f:attribute name="roles" value="admin" />
	</ui:define>
	<ui:define name="roles">
		<f:attribute name="roles" value="admin" />
	</ui:define>

	<ui:define name="title">
		<h:outputText value="Lista Utenti" />
	</ui:define>

	<ui:define name="content">
		<h:form id="central">
			<center>
				<p:panel header="Lista Pagine">
					<h:panelGrid columns="7" rendered="true">
						<h:outputLabel for="name" value="Nome:" />
						<h:inputText id="name" value="#{userController.search.obj.name}" />

						<h:outputLabel for="email" value="Email:" />
						<h:inputText id="email"
							value="#{userController.search.obj.username}" />

						<h:outputLabel for="ruolo" value="Ruolo: " />
						<h:selectOneMenu id="ruolo"
							value="#{userController.search.obj.role}">
							<f:selectItems value="#{ruoliItemsWithAdminAndAll}" />
						</h:selectOneMenu>
						<p:commandButton action="#{userController.reloadAjax}"
							value="Cerca" ajax="true" immediate="false" update="userList" />
					</h:panelGrid>
				</p:panel>
				<br />
				<p:panel header="Lista Utenti">
					<p:dataTable id="userList" rowIndexVar="rowIndex" var="user"
						value="#{userController.model}" rows="#{userController.pageSize}"
						paginator="true" dynamic="true">
						<p:column width="50">
							<center>
								<h:outputText value="#{rowIndex+1} " />
							</center>
						</p:column>
						<p:column>
							<f:facet name="header">
							nome
						</f:facet>
							<h:outputText value="#{user.name}" />
						</p:column>
						<p:column>
							<f:facet name="header">
							username
						</f:facet>
							<h:outputText value="#{user.username}" />
						</p:column>

						<p:column>
							<f:facet name="header">
							ruoli
						</f:facet>
							<h:outputText value="#{user.roleNames}" />
						</p:column>

						<p:column rendered="false">
							<f:facet name="header">
							email
						</f:facet>
							<h:outputText value="#{user.email}" />
						</p:column>

						<p:column>
							<f:facet name="header">operazioni</f:facet>
							<center>
								<h:commandLink action="#{userController.modElement}"
									value="modifica" />
							</center>
						</p:column>
					</p:dataTable>
				</p:panel>
				<br /> <br />
				<h:panelGrid columns="1">
					<h:commandButton action="#{userController.addElement}"
						value="Aggiungi" />
				</h:panelGrid>
			</center>

		</h:form>

	</ui:define>
</ui:composition>